﻿using UnityEngine.UI;

namespace Common
{
    using UnityEngine;
    using System.Collections;

    public class FPSDisplay : MonoBehaviour
    {

        public Text text;
        float deltaTime = 0.0f;

        void Update()
        {
            deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
        }

        void OnGUI()
        {
            float msec = deltaTime * 1000.0f;
            float fps = 1.0f / deltaTime;
            string fps_str = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
            text.text = fps_str;
        }
    }
}